Skip to content

Conversation

@picklecolor2
Copy link

When using the API to query timesheets_deleted, line 11 causes a problem where the query looks for timesheet_deleteds. This special cases for that class, though I'm a python amateur and there may be a cleaner way to do that.

When using the API to query timesheets_deleted, line 11 causes a problem where the query looks for timesheet_deleteds. This special cases for that class, though I'm a python amateur and there may be a cleaner way to do that.
Looks like some time recently the JSON data returned changed from a string 'true' to the value True. This will allow the wrapper to pull more than the first page of records again.
Copy link

@shree-y shree-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test in test.py.
I used this to test your changes. Please feel free to make improvements to my test.

  # Deleted timesheets
    timesheets_deleted = None
    timesheets_deleted = api.timesheets_deleted.where(modified_since=datetime(2015,7,1), user_ids=[current_user.id]).all()
    if len(timesheets_deleted) > 0:
        print (' - Found {0} deleted timesheets'.format(len(timesheets_deleted)))
    else:
        print(' - No deleted timesheets found')
        return

self.model = repo.model
self.name = class_to_endpoint(self.model.__name__) + ('' if is_singleton else 's')
if isinstance(self.repo, repos.TimesheetsDeleted):
self.name = 'timesheets_deleted'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you have here works, but wondering if it is better to create a method in repository.py to set the name.
We can avoid one-off logic like this, and also if new endpoints are added that follow timesheets_deleted pattern, then we wouldn't need to update the logic here again.
Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants